#ifndef  __WIRELESS_COMM_H__
#define  __WIRELESS_COMM_H__


#define  READER_PROPERTY_INOUT_IN       0x01
#define  READER_PROPERTY_INOUT_OUT      0x02

typedef struct _wireless_comm_control 
{
   INT8U  WirelessCommStatus;
   INT8U  bUHFCommEstablished;
   INT8U  PreviousSentCmd;
   INT8U  RecvOverTimerID;
   INT8U  RetryCnt;
   INT8U  bResult;
}WIRELESS_COMM_CONTROL;

typedef  struct  __reader_property
{
    INT8U  UHF_CommChannel;
    INT8U  UHF_Power;
    INT8U  InOut;
}READER_PROPERTY;

#define  WIRELESS_COMM_START       (0x00)
#define  WIRELESS_COMM_SUCCESS     (0x01)
#define  WIRELESS_COMM_RETRY       (0x02)
#define  WIRELESS_COMM_TRYING      (0x03)
#define  WIRELESS_COMM_FAILED      (0x04)

#define  WIRELESS_COMM_LF_WAKE_UP_OK                        (0x01)
#define  WIRELESS_COMM_LF_WAKE_UP_FAILED                    (0x02)


#define WIRELESS_COMM_COMMAND(__cmd , __func)                                          \
{                                                                                      \
    INT8U err, CommStatus;                                                             \
    CommStatus = WIRELESS_COMM_START;                                                  \
    WirelessCommUHF_Start();                                                           \
    do                                                                                 \
    {                                                                                  \
      CommStatus = WirelessCommUHF_Trans(__cmd);                                       \
      if ( CommStatus == WIRELESS_COMM_FAILED)                                         \
      {                                                                                \
          break;                                                                       \
      }                                                                                \
      else if(CommStatus == WIRELESS_COMM_RETRY)                                       \
      {                                                                                \
         __func;                                                                       \
      }                                                                                \
      if(WirelessCommUHF_Recv(__cmd) == WIRELESS_COMM_SUCCESS)                         \
      {                                                                                \
          CommStatus = WIRELESS_COMM_SUCCESS;                                          \
          break;                                                                       \
      }                                                                                \
     }while((CommStatus!=WIRELESS_COMM_FAILED)&&(CommStatus!=WIRELESS_COMM_SUCCESS));  \
     WirelessCommUHF_End(CommStatus);                                                  \
}  

extern  INT8U   UHF_CommChannel;

void   WirelessCommInit(void);
void   WirelessCommReset(void);
INT8U  WirelessCommLFWakeUp(void);
INT8U  WirelessCommUHF_Start(void);
INT8U  WirelessCommUHF_Trans(INT8U Trans_Cmd);
INT8U  WirelessCommUHF_Recv(INT8U Recv_Cmd);
void   WirelessCommUHF_End(INT8U CommStatus);
INT8U  WirelessComm_IsCmdSuccess(void);
void   WirelessComm_TimerUpdate(void);
void   WirelessComm_TimerStart(void);
void   WirelessComm_TimerLoop(void);
void   WirelessComm_TimerInit(void);
#endif